// 时分秒转换为妙
export function timeEvent(e) {
  var time = e;
  var len = time && time.indexOf(':') > -1 ? time.split(":") : '';
  if (len.length == 3) {
    var hour = time.split(":")[0];
    var min = time.split(":")[1];
    var sec = time.split(":")[2];
    return Number(hour * 3600) + Number(min * 60) + Number(sec);
  }
  if (len.length == 2) {
    var min = time.split(":")[0];
    var sec = time.split(":")[1];
    return Number(min * 60) + Number(sec);
  }
  if (len.length == 1) {
    var sec = time.split(":")[0];
    return Number(sec);
  }
}
// 秒转换为时分秒
export function formatSeconds(value) {
  var secondTime = parseInt(value); // 秒
  var minuteTime = 0; // 分
  var hourTime = 0; // 小时
  if (secondTime >= 60) {
    minuteTime = parseInt(secondTime / 60);
    secondTime = parseInt(secondTime % 60);
    if (minuteTime >= 60) {
      hourTime = parseInt(minuteTime / 60);
      minuteTime = parseInt(minuteTime % 60);
    }
  }
  var result =
    "" +
    (parseInt(secondTime) < 10
      ? "0" + parseInt(secondTime)
      : parseInt(secondTime));

  // if (minuteTime > 0) {
  result =
    "" +
    (parseInt(minuteTime) < 10
      ? "0" + parseInt(minuteTime)
      : parseInt(minuteTime)) +
    ":" +
    result;
  // }
  // if (hourTime > 0) {
  // result =
  //   "" +
  //   (parseInt(hourTime) < 10 ? "0" + parseInt(hourTime) : parseInt(hourTime)) +
  //   ":" +
  //   result;
  // }
  return result;
}
